package arm.dic.bean;

import arm.dic.entity.DicPeriod;
import arm.common.manager.TableManager;
import arm.db.tools.DBManager;

public class  DicPeriodBean
{
    private DicPeriod period;
    private TableManager<DicPeriod> tableManager;


    public DicPeriod getPeriod() {
        return period;
    }

    public void setPeriod(DicPeriod period) {
        this.period = period;
    }

    public String create()
    {
        period = new DicPeriod();
        return "editDicPeriod";
    }


    public String save()
    {
        DBManager.saveOrUpdate(getPeriod());
        return viewTable();
    }

    public String edit()
    {
        setPeriod(getTableManager().getSelectedObj());
        return "editDicPeriod";
    }

    public String cancel()
    {
        return viewTable();
    }

    public String viewTable ()
    {
        getTableManager().readFromDB();
        return "viewDicPeriodTable" ;
    }

    public TableManager<DicPeriod> getTableManager() {
        if (tableManager == null)
        {
            tableManager = new TableManager<DicPeriod>(DicPeriod.class);
        }
        return tableManager;
    }

    public void setTableManager(TableManager<DicPeriod> tableManager) {
        this.tableManager = tableManager;
    }

    public void delete ()
    {
        DBManager.delete(getTableManager().getSelectedObj());
        getTableManager().readFromDB();
    }


}


